<?php

namespace Common\Lib\Upload\ImgManager;

class Qiniu implements IImgManager
{
    private $img;
    private $key;
    private $options;

    public function __construct(array $options)
    {
        $this->options = $options;
    }

    public function set_img(array $img)
    {
        $this->img = $img;
        $this->key = $this->img['savepath'] . $this->img['savename'];
    }

    public function path()
    {
        return $this->url();
    }

    public function url()
    {
        return 'http://' . $this->options['domain'] . '/' . urlencode($this->key);
    }
}